﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MsTestUtilities.RowTests;

namespace MsTestUtilitiesTests.RowTests
{
    [TestClass]
    public class ExceptionTests
    {
        [TestMethod]
        public void TestMethod1()
        {
            new TestScenarioBuilder<int, int, string>()
                .For(Throws)
                .Given(2, 2).ExpectException<InvalidOperationException>().Because("When the numbers are equal, an exception should be thrown")                
                .Given(2, 2).ExpectException<InvalidOperationException>("My exception").Because("When the numbers are equal, an exception should be thrown")
                .Given(2, 2).ExpectException<InvalidOperationException>(e => e.Message == "My exception").Because("When the numbers are equal, an exception should be thrown")
                .Evaluate();
        }

        private string Throws(int a, int b)
        {            
            if (a == b)
            {
              throw new InvalidOperationException("My exception");            
            }

            return (a+b).ToString();        
        }
    }
}
